Skip to content

test: migrate the tests to cycle/testing - #61

Merged
roxblnfk merged 10 commits into
1.xfrom
test/testo
Nov 20, 2026
Merged

roxblnfk merged 10 commits into
1.xfrom
test/testo

Conversation

@roxblnfk

@roxblnfk roxblnfk commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

What was changed

  • Tests run on the shared cycle/testing harness (^0.1.1, from its VCS repository until it reaches Packagist): testo.php is built on Cycle\Testing\Config with a Unit suite and one Acceptance/<Driver> suite per driver, with transaction isolation and an in-memory SQLite secondary database.
  • tests/Stub/OrmEnvironment keeps only what is specific to this package (entities, seed, behaviour-aware ORM, Facade binding) and plugs into the harness hooks; Unit tests take their ORM from Cycle\Testing\ORM\Memory. The acceptance scenarios live in one tests/Acceptance/Common/ActiveRecordTest.
  • Composer scripts: test:<driver> runs that driver's suites (test:pgsql is now test:postgres), db:up / db:down start and stop the databases from the cycle/testing compose file. Infection runs Unit and Acceptance/SQLite.
  • CI: .github/workflows/testing.yml calls the shared cycle/gh-actions Testo workflow with coverage on. Unit and SQLite run on PHP 8.2–8.6 with highest dependencies and on 8.2 with lowest; MySQL, Postgres and SQLServer run on PHP 8.2 and 8.6 (highest, plus lowest on 8.2); every job runs with DB_REQUIRED=1, so an unreachable database fails the job instead of skipping; coverage goes to Codecov with one flag per suite. It replaces the Unit and coverage jobs of testing.yml and testing-mysql.yml, testing-pgsql.yml, testing-sqlserver.yml.
Suite Baseline (own Testo harness) Now
Unit 10 tests, 19 assertions 10 tests, 19 assertions
Acceptance SQLite 43 tests, 8 errors 42 passed, 1 skipped
Acceptance MySQL / Postgres / SQLServer 43 each, not run at baseline 43 each
  • The 8 SQLite errors predate this PR and came from test order: saveOrFailThrowsOnUniqueViolation leaves its failed insert in the prepared statement cache of cycle/database without a reset, and the next user insert fails with SQLSTATE[HY000]: General error: 21 bad parameter or other API misuse (cycle/database#131). That test is skipped on SQLite with a link to the issue until it is fixed; it still runs on MySQL, Postgres and SQLServer.
  • Deleted: the local harness in tests/Acceptance/Testo (database plugin, interceptor, connection pool, WithoutTransaction), the per-driver subclasses, BaseTestCase, tests/docker-compose.yml, the CI wait loops and connection env, and the test:acceptance, test:no-driver and test:pgsql scripts.
  • Deliberate difference: drivers are selected by suite (--suite=Acceptance/MySQL) instead of --group=driver-*.

Why?

One harness for all Cycle packages: databases, driver matrix and isolation come from cycle/testing instead of a per-repo copy.

Checklist

  • Tested
    • Unit and SQLite suites run locally
    • MySQL, Postgres and SQLServer suites run in CI
    • Unit tests added

testo.php stays in charge for now: the current tests depend on its custom plugin in tests/Acceptance/Testo, so testo.cycle.php only stages the cycle/testing config they move to.

Assisted-By: Claude Opus 5.5 <[email protected]>
cycle/testing provides the database plugin, transaction isolation and the per-driver run that tests/Acceptance/Testo implemented locally; tests/Stub/OrmEnvironment keeps only what is specific to this package (entities, seed, behaviour-aware ORM, Facade binding) and plugs into the harness hooks.

Assisted-By: Claude Opus 5.5 <[email protected]>
The package compose file waits for the database itself, which replaces the hand-written wait loops; DB_REQUIRED=1 makes an unreachable database fail the job instead of skipping its tests. test:pgsql becomes test:postgres to match the suite names.

Assisted-By: Claude Opus 5.5 <[email protected]>
@roxblnfk
roxblnfk requested a review from a team November 20, 2026 11:54
@roxblnfk
roxblnfk requested a review from lotyp as a code owner November 20, 2026 11:54
@codecov

codecov Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.00%. Comparing base (8525480) to head (4106d9a).

Additional details and impacted files
@@            Coverage Diff             @@
##              1.x      #61      +/-   ##
==========================================
+ Coverage   93.26%   95.00%   +1.73%     
==========================================
  Files          12       10       -2     
  Lines         104      100       -4     
==========================================
- Hits           97       95       -2     
+ Misses          7        5       -2     
Flag Coverage Δ
mysql 82.82% <ø> (?)
postgres 82.82% <ø> (?)
sqlite 82.82% <ø> (?)
sqlserver 82.82% <ø> (?)
unit 16.16% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

The Testo bridge of Infection passes testFrameworkOptions as one argument, so two --suite options in it select no suite at all.

Assisted-By: Claude Opus 5.5 <[email protected]>
The failed INSERT ... RETURNING stays in the prepared statement cache of cycle/database without a reset, and on SQLite the next user insert of the suite fails with "21 bad parameter or other API misuse": the 8 SQLite errors on PHP 8.2 and 8.3 in CI and on every local build. The cache should be fixed in cycle/database; this keeps the suite independent of test order until then.

Assisted-By: Claude Opus 5.5 <[email protected]>
Assisted-By: Claude Opus 5.5 <[email protected]>
… is fixed

The failed insert stays unreset in the statement cache of cycle/database and breaks the next user insert on SQLite. Skipping the one test that triggers it keeps the SQLite suite running and reports the skip with the issue link, instead of clearing the cache from the test.

Assisted-By: Claude Opus 5.5 <[email protected]>
@roxblnfk
roxblnfk merged commit 57ed72b into 1.x Nov 20, 2026
26 checks passed
@roxblnfk
roxblnfk deleted the test/testo branch November 20, 2026 13:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant